// 封装时间格式化hooks
import { message } from 'ant-design-vue';

type strNum = string | number

function useDateText(value:string) {
  if(!value) {
    message.warning('暂未选择时间');
    return
  }
  // 获取时间戳
  let date = new Date(value);
  let y = date.getFullYear()
  let m:strNum = date.getMonth()+1;
  let d:strNum = date.getDate();
  if(m<10) m = '0' + m;
  if(d<10) d = '0' + d;

  return y + '-' + m + '-' + d
}

export default useDateText;